package com.example.sicnuaccountingapp.data.dao

import androidx.room.*
import com.example.sicnuaccountingapp.data.entity.Budget
import kotlinx.coroutines.flow.Flow

@Dao
interface BudgetDao {
    @Insert
    suspend fun insert(budget: Budget): Long

    @Update
    suspend fun update(budget: Budget)

    @Delete
    suspend fun delete(budget: Budget)

    @Query("SELECT * FROM budgets WHERE userId = :userId")
    fun getAllBudgets(userId: Long): Flow<List<Budget>>

    @Query("SELECT * FROM budgets WHERE userId = :userId AND startDate <= :date AND endDate >= :date")
    fun getActiveBudgets(userId: Long, date: Long = System.currentTimeMillis()): Flow<List<Budget>>
} 